drawio_dsl 0.5.7 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. checksums.yaml +4 -4
  2. data/.builders/.data/shapes.json +49 -22
  3. data/.builders/.templates/basic/dom_builder_shapes.rb +2 -2
  4. data/.builders/.templates/basic/drawio_extensions.rb +57 -0
  5. data/.builders/.templates/basic/drawio_shapes.rb +2 -2
  6. data/.builders/blueprint/shapes.rb +10 -5
  7. data/.builders/generators/10-transform-drawio-js.rb +195 -0
  8. data/.builders/generators/20-drawio-extensions.rb +41 -0
  9. data/.builders/generators/project_plans/drawio_dsl.rb +30 -21
  10. data/.builders/generators/sample_diagrams/15-grid-direction.rb +0 -8
  11. data/.builders/generators/sample_diagrams/20-styles.rb +1 -2
  12. data/.builders/generators/sample_diagrams/30-html-shapes.rb +48 -0
  13. data/.rubocop.yml +1 -0
  14. data/CHANGELOG.md +28 -0
  15. data/docs/extensions/analyti_cs.svg +3 -0
  16. data/docs/extensions/android_inputs.svg +3 -0
  17. data/docs/extensions/app_services.svg +3 -0
  18. data/docs/extensions/appliances.svg +3 -0
  19. data/docs/extensions/arrows.svg +3 -0
  20. data/docs/extensions/aws_17___analyti_cs.svg +3 -0
  21. data/docs/extensions/aws_17___application_services.svg +3 -0
  22. data/docs/extensions/aws_17___artificial_intelligence.svg +3 -0
  23. data/docs/extensions/aws_17___business_productivity.svg +3 -0
  24. data/docs/extensions/aws_17___compute.svg +3 -0
  25. data/docs/extensions/aws_17___contact_center.svg +3 -0
  26. data/docs/extensions/aws_17___containers.svg +3 -0
  27. data/docs/extensions/aws_17___database.svg +3 -0
  28. data/docs/extensions/aws_17___desktop_app_straning.svg +3 -0
  29. data/docs/extensions/aws_17___developer_tools.svg +3 -0
  30. data/docs/extensions/aws_17___game_development.svg +3 -0
  31. data/docs/extensions/aws_17___general.svg +3 -0
  32. data/docs/extensions/aws_17___io_t.svg +3 -0
  33. data/docs/extensions/aws_17___management.svg +3 -0
  34. data/docs/extensions/aws_17___messaging.svg +3 -0
  35. data/docs/extensions/aws_17___migration.svg +3 -0
  36. data/docs/extensions/aws_17___mobile_services.svg +3 -0
  37. data/docs/extensions/aws_17___networking_content_delivery.svg +3 -0
  38. data/docs/extensions/aws_17___on_demand_workforce.svg +3 -0
  39. data/docs/extensions/aws_17___sdks.svg +3 -0
  40. data/docs/extensions/aws_17___serurity_identity_and_compliance.svg +3 -0
  41. data/docs/extensions/aws_17___storage.svg +3 -0
  42. data/docs/extensions/aws_19___application_integration.svg +3 -0
  43. data/docs/extensions/aws_19___ar_vr.svg +3 -0
  44. data/docs/extensions/aws_19___blockchain.svg +3 -0
  45. data/docs/extensions/aws_19___business_applications.svg +3 -0
  46. data/docs/extensions/aws_19___compute.svg +3 -0
  47. data/docs/extensions/aws_19___cost_management.svg +3 -0
  48. data/docs/extensions/aws_19___customer_engagement.svg +3 -0
  49. data/docs/extensions/aws_19___database.svg +3 -0
  50. data/docs/extensions/aws_19___desktop_app_streaming.svg +3 -0
  51. data/docs/extensions/aws_19___developer_tools.svg +3 -0
  52. data/docs/extensions/aws_19___ec2_instance_types.svg +3 -0
  53. data/docs/extensions/aws_19___game_tech.svg +3 -0
  54. data/docs/extensions/aws_19___general.svg +3 -0
  55. data/docs/extensions/aws_19___groups_note_repeated_below_without_v2.svg +3 -0
  56. data/docs/extensions/aws_19___internet_of_things.svg +3 -0
  57. data/docs/extensions/aws_19___machine_learning.svg +3 -0
  58. data/docs/extensions/aws_19___management_governance.svg +3 -0
  59. data/docs/extensions/aws_19___media_services.svg +3 -0
  60. data/docs/extensions/aws_19___migration_transfer.svg +3 -0
  61. data/docs/extensions/aws_19___mobile.svg +3 -0
  62. data/docs/extensions/aws_19___networking_content_delivery.svg +3 -0
  63. data/docs/extensions/aws_19___roboti_cs.svg +3 -0
  64. data/docs/extensions/aws_19___satellite.svg +3 -0
  65. data/docs/extensions/aws_19___security_identity_compliance.svg +3 -0
  66. data/docs/extensions/aws_19___storage.svg +3 -0
  67. data/docs/extensions/aws_19_analyti_cs.svg +3 -0
  68. data/docs/extensions/aws_general.svg +3 -0
  69. data/docs/extensions/azure2019.svg +3 -0
  70. data/docs/extensions/azure_cloud.svg +3 -0
  71. data/docs/extensions/azure_enterprise.svg +3 -0
  72. data/docs/extensions/azure_vms.svg +3 -0
  73. data/docs/extensions/basic_network_shapes.svg +3 -0
  74. data/docs/extensions/beds.svg +3 -0
  75. data/docs/extensions/bpmn_2_0.svg +3 -0
  76. data/docs/extensions/cisco_basic.svg +3 -0
  77. data/docs/extensions/cisco_extended.svg +3 -0
  78. data/docs/extensions/common_elements.svg +3 -0
  79. data/docs/extensions/computers_and_monitors.svg +3 -0
  80. data/docs/extensions/containers.svg +3 -0
  81. data/docs/extensions/content_delivery.svg +3 -0
  82. data/docs/extensions/couches.svg +3 -0
  83. data/docs/extensions/cubicle_walls.svg +3 -0
  84. data/docs/extensions/data_flow.svg +3 -0
  85. data/docs/extensions/database.svg +3 -0
  86. data/docs/extensions/deployment.svg +3 -0
  87. data/docs/extensions/desks.svg +3 -0
  88. data/docs/extensions/detailed_network_diagrams.svg +3 -0
  89. data/docs/extensions/developer_tools.svg +3 -0
  90. data/docs/extensions/doors_windows.svg +3 -0
  91. data/docs/extensions/ec2.svg +3 -0
  92. data/docs/extensions/electrical.svg +3 -0
  93. data/docs/extensions/electroni_cs.svg +3 -0
  94. data/docs/extensions/enterprise_application.svg +3 -0
  95. data/docs/extensions/equipment.svg +3 -0
  96. data/docs/extensions/ext_shapes.svg +3 -0
  97. data/docs/extensions/flowchart.svg +3 -0
  98. data/docs/extensions/geometric_shapes.svg +3 -0
  99. data/docs/extensions/google_cloud_platform.svg +3 -0
  100. data/docs/extensions/heat_exchangers.svg +3 -0
  101. data/docs/extensions/i_os_6_i_pad_controls.svg +3 -0
  102. data/docs/extensions/i_os_6_i_pad_elements.svg +3 -0
  103. data/docs/extensions/i_os_6_i_pad_icons.svg +3 -0
  104. data/docs/extensions/i_os_6_i_phone_controls.svg +3 -0
  105. data/docs/extensions/i_os_6_i_phone_elements.svg +3 -0
  106. data/docs/extensions/i_os_6_i_phone_icons.svg +3 -0
  107. data/docs/extensions/i_os_devices.svg +3 -0
  108. data/docs/extensions/i_os_icons.svg +3 -0
  109. data/docs/extensions/i_os_mockups.svg +3 -0
  110. data/docs/extensions/i_os_ui_components.svg +3 -0
  111. data/docs/extensions/i_pad_elements.svg +3 -0
  112. data/docs/extensions/i_phone_elements.svg +3 -0
  113. data/docs/extensions/information.svg +3 -0
  114. data/docs/extensions/instruments.svg +3 -0
  115. data/docs/extensions/internet_of_things.svg +3 -0
  116. data/docs/extensions/kanban.svg +3 -0
  117. data/docs/extensions/kitchen.svg +3 -0
  118. data/docs/extensions/kubernetes_icons.svg +3 -0
  119. data/docs/extensions/logic_gates.svg +3 -0
  120. data/docs/extensions/materials.svg +3 -0
  121. data/docs/extensions/message_routing.svg +3 -0
  122. data/docs/extensions/message_transformation.svg +3 -0
  123. data/docs/extensions/messaging_channels.svg +3 -0
  124. data/docs/extensions/messaging_endpoints.svg +3 -0
  125. data/docs/extensions/messaging_systems.svg +3 -0
  126. data/docs/extensions/mind_map.svg +3 -0
  127. data/docs/extensions/misc.svg +3 -0
  128. data/docs/extensions/misc_floorplan.svg +3 -0
  129. data/docs/extensions/miscellaneous.svg +3 -0
  130. data/docs/extensions/mobile_services.svg +3 -0
  131. data/docs/extensions/network.svg +3 -0
  132. data/docs/extensions/networking.svg +3 -0
  133. data/docs/extensions/on_demand.svg +3 -0
  134. data/docs/extensions/piping.svg +3 -0
  135. data/docs/extensions/power_sources.svg +3 -0
  136. data/docs/extensions/processes.svg +3 -0
  137. data/docs/extensions/pumps.svg +3 -0
  138. data/docs/extensions/repeated_from_the_above.svg +3 -0
  139. data/docs/extensions/restroom.svg +3 -0
  140. data/docs/extensions/s3.svg +3 -0
  141. data/docs/extensions/sdks.svg +3 -0
  142. data/docs/extensions/security_identity.svg +3 -0
  143. data/docs/extensions/server_racks.svg +3 -0
  144. data/docs/extensions/shipments.svg +3 -0
  145. data/docs/extensions/site_map.svg +3 -0
  146. data/docs/extensions/stairs.svg +3 -0
  147. data/docs/extensions/standard.svg +3 -0
  148. data/docs/extensions/system_management.svg +3 -0
  149. data/docs/extensions/tables_chairs.svg +3 -0
  150. data/docs/extensions/technology.svg +3 -0
  151. data/docs/extensions/transistors.svg +3 -0
  152. data/docs/extensions/ui_containers.svg +3 -0
  153. data/docs/extensions/ui_input.svg +3 -0
  154. data/docs/extensions/ui_menus.svg +3 -0
  155. data/docs/extensions/ui_misc.svg +3 -0
  156. data/docs/extensions/ui_widgets.svg +3 -0
  157. data/docs/extensions/uml_class_diagram.svg +3 -0
  158. data/docs/extensions/uml_component.svg +3 -0
  159. data/docs/extensions/uml_entity_relationship.svg +3 -0
  160. data/docs/extensions/uml_sequence.svg +3 -0
  161. data/docs/extensions/uml_state_activity.svg +3 -0
  162. data/docs/extensions/uml_use_case.svg +3 -0
  163. data/docs/extensions/value_stream_mapping.svg +3 -0
  164. data/docs/extensions/valves.svg +3 -0
  165. data/docs/extensions/venn_gradient.svg +3 -0
  166. data/docs/extensions/venn_plain.svg +3 -0
  167. data/docs/extensions/vessels.svg +3 -0
  168. data/docs/extensions.md +614 -0
  169. data/docs/project_done.svg +1 -1
  170. data/docs/project_in_progress.svg +1 -1
  171. data/docs/project_todo.svg +1 -1
  172. data/docs/samples/grid-direction-horizontal.svg +1 -1
  173. data/docs/samples/grid-direction-vertical.svg +1 -1
  174. data/docs/samples/html-shapes.svg +3 -0
  175. data/docs/samples/samples.md +4 -0
  176. data/docs/samples/samples.svg +1 -1
  177. data/docs/samples/styles-glass.svg +1 -1
  178. data/docs/samples/styles-plain.svg +1 -1
  179. data/docs/samples/styles-rounded.svg +1 -1
  180. data/docs/samples/styles-shadow.svg +1 -1
  181. data/docs/samples/styles-sketch.svg +1 -1
  182. data/docs/samples/themes-random.svg +1 -1
  183. data/lib/drawio_dsl/configuration_shapes.rb +14 -8
  184. data/lib/drawio_dsl/dom_builder.rb +23 -8
  185. data/lib/drawio_dsl/dom_builder_shapes.rb +97 -82
  186. data/lib/drawio_dsl/drawio_extensions.json +14024 -0
  187. data/lib/drawio_dsl/drawio_extensions.rb +4599 -0
  188. data/lib/drawio_dsl/drawio_extensions_active.rb +32 -0
  189. data/lib/drawio_dsl/drawio_shapes.rb +114 -96
  190. data/lib/drawio_dsl/formatters/_.rb +8 -0
  191. data/lib/drawio_dsl/formatters/base_formatter.rb +24 -0
  192. data/lib/drawio_dsl/formatters/factory.rb +33 -0
  193. data/lib/drawio_dsl/formatters/html_builder.rb +84 -0
  194. data/lib/drawio_dsl/formatters/interface_formatter.rb +53 -0
  195. data/lib/drawio_dsl/formatters/klass_formatter.rb +52 -0
  196. data/lib/drawio_dsl/formatters/style_builder.rb +63 -0
  197. data/lib/drawio_dsl/layout_engine.rb +17 -7
  198. data/lib/drawio_dsl/schema/_.rb +7 -4
  199. data/lib/drawio_dsl/schema/diagram.rb +1 -1
  200. data/lib/drawio_dsl/schema/layouts/flex_layout.rb +1 -2
  201. data/lib/drawio_dsl/schema/layouts/grid_layout.rb +1 -2
  202. data/lib/drawio_dsl/schema/layouts/layout.rb +0 -3
  203. data/lib/drawio_dsl/schema/node.rb +16 -3
  204. data/lib/drawio_dsl/schema/node_list.rb +20 -1
  205. data/lib/drawio_dsl/schema/page.rb +14 -7
  206. data/lib/drawio_dsl/schema/shapes/interface.rb +9 -0
  207. data/lib/drawio_dsl/schema/shapes/klass.rb +9 -0
  208. data/lib/drawio_dsl/schema/shapes/shape.rb +25 -11
  209. data/lib/drawio_dsl/schema/shapes/todo.rb +9 -0
  210. data/lib/drawio_dsl/schema/virtual/anchor.rb +2 -0
  211. data/lib/drawio_dsl/version.rb +1 -1
  212. data/lib/drawio_dsl/xml_builder.rb +4 -9
  213. data/lib/drawio_dsl.rb +3 -0
  214. data/package-lock.json +2 -2
  215. data/package.json +1 -1
  216. metadata +174 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbcff9217d4dba5b4cde6bc9d0fd2e9448ef7c6d953ce721055c3fb09ae8e6b6
4
- data.tar.gz: 618b5bb6db0a4688a4263f671ef83d8f0f188553ced55e9a975898abf84bb5ae
3
+ metadata.gz: 1032026c1c77b8743c93aab81ebb8f78ec972cb7f0997823d9b64837e6ab4c34
4
+ data.tar.gz: 26b21a1aa90b3740c6b080bc650af25ee4f386ce673ca71efe04723d1288cbc4
5
5
  SHA512:
6
- metadata.gz: 55c4572a400d3a101261243c417b34d202303954eb83078ded151e4cd3bf7f8b3af1b39214cdbd97b899ce4884a1a9ca85a03b85a66eb9bbbf14e836da662e55
7
- data.tar.gz: bdef286ff06b834b0cf93cc1a3f59dbf966040da92ebaf787722c240d922b9a4b5e3be38f6caa9507abf1f007099abff7ba8b36d4aff60d5ad3467245c089173
6
+ metadata.gz: 980bd6c45544bd734fb15b863d59e1e2ffb3e45c9ad3ccb5a9b93896cd2658a9009bd7572d1312698930da2193d17215f73ff823ce8dd2c138cda5655bda80ff
7
+ data.tar.gz: 2f4b640efce45016ac846e37078d17ffda64685c966dbd486c12f7164fdb6b5791c0bbb7c6b0ddc9d17c38f196a5eb8a35abb03b4c0dea64e70d5392c78aa06f
@@ -134,6 +134,42 @@
134
134
  "h": 160,
135
135
  "style_modifiers": "shape=cloud"
136
136
  },
137
+ {
138
+ "type": "container",
139
+ "text_only": false,
140
+ "x": 0,
141
+ "y": 0,
142
+ "w": 160,
143
+ "h": 160,
144
+ "style_modifiers": "swimlane"
145
+ },
146
+ {
147
+ "type": "container2",
148
+ "text_only": false,
149
+ "x": 0,
150
+ "y": 0,
151
+ "w": 160,
152
+ "h": 160,
153
+ "style_modifiers": "swimlane;horizontal=0"
154
+ },
155
+ {
156
+ "type": "container3",
157
+ "text_only": false,
158
+ "x": 0,
159
+ "y": 0,
160
+ "w": 160,
161
+ "h": 160,
162
+ "style_modifiers": "swimlane;startSize=50"
163
+ },
164
+ {
165
+ "type": "container4",
166
+ "text_only": false,
167
+ "x": 0,
168
+ "y": 0,
169
+ "w": 160,
170
+ "h": 160,
171
+ "style_modifiers": "swimlane;resizable=0"
172
+ },
137
173
  {
138
174
  "type": "cross",
139
175
  "text_only": false,
@@ -189,40 +225,22 @@
189
225
  "style_modifiers": "shape=hexagon"
190
226
  },
191
227
  {
192
- "type": "container",
193
- "text_only": false,
194
- "x": 0,
195
- "y": 0,
196
- "w": 160,
197
- "h": 160,
198
- "style_modifiers": "swimlane"
199
- },
200
- {
201
- "type": "container2",
202
- "text_only": false,
203
- "x": 0,
204
- "y": 0,
205
- "w": 160,
206
- "h": 160,
207
- "style_modifiers": "swimlane;horizontal=0"
208
- },
209
- {
210
- "type": "container3",
228
+ "type": "interface",
211
229
  "text_only": false,
212
230
  "x": 0,
213
231
  "y": 0,
214
232
  "w": 160,
215
233
  "h": 160,
216
- "style_modifiers": "swimlane;startSize=50"
234
+ "style_modifiers": "align=left;overflow=fill;fontSize=12;fontFamily=Helvetica"
217
235
  },
218
236
  {
219
- "type": "container4",
237
+ "type": "klass",
220
238
  "text_only": false,
221
239
  "x": 0,
222
240
  "y": 0,
223
241
  "w": 160,
224
242
  "h": 160,
225
- "style_modifiers": "swimlane;resizable=0"
243
+ "style_modifiers": "align=left;overflow=fill;fontSize=12;fontFamily=Helvetica"
226
244
  },
227
245
  {
228
246
  "type": "note",
@@ -287,6 +305,15 @@
287
305
  "h": 50,
288
306
  "style_modifiers": "verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.tick"
289
307
  },
308
+ {
309
+ "type": "todo",
310
+ "text_only": false,
311
+ "x": 0,
312
+ "y": 0,
313
+ "w": 300,
314
+ "h": 60,
315
+ "style_modifiers": ""
316
+ },
290
317
  {
291
318
  "type": "face",
292
319
  "text_only": false,
@@ -6,8 +6,8 @@ module DrawioDsl
6
6
  module DomBuilderShapes
7
7
  {{#each shapes}}
8
8
 
9
- def add_{{snake ./type}}(**opts)
10
- {{snake ./type}} = DrawioDsl::Schema::{{camel ./type}}.new(current_page, **opts)
9
+ def add_{{snake ./type}}(**opts, &block)
10
+ {{snake ./type}} = DrawioDsl::Schema::{{camel ./type}}.new(current_page, **opts, &block)
11
11
  add_shape({{snake ./type}})
12
12
  end
13
13
  {{/each}}
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ # :nocov:
5
+ class DrawIoExtensions
6
+
7
+ attr_reader :sections
8
+ attr_reader :current_section
9
+
10
+ def initialize
11
+ @sections = []
12
+ end
13
+
14
+ def section(name)
15
+ @current_section = {
16
+ name: name,
17
+ shapes: []
18
+ }
19
+ @sections << current_section
20
+
21
+ yield if block_given?
22
+ end
23
+
24
+ def shape(name, style, original_name)
25
+ shape = {
26
+ name: name,
27
+ style: style,
28
+ original_name: original_name
29
+ }
30
+ current_section[:shapes] << shape
31
+ shape
32
+ end
33
+
34
+ def to_h
35
+ {
36
+ sections: @sections.map(&:to_h)
37
+ }
38
+ end
39
+
40
+ # This methods was generated using Extensions.js
41
+ # This generation can be improved over time and the code to do the generation
42
+ # can be found in the .builders/generators/10-transform-drawio-js.rb.
43
+ # original source: ~/dev/tools/drawio-desktop/drawio/src/main/webapp/js/diagramly/Extensions.js
44
+ def build_extensions
45
+ # Constants
46
+ {{{constants}}}
47
+ {{#each sections}}
48
+ section :{{snake ./name}} do
49
+ {{#each ./shapes}}
50
+ shape :{{padr (snake ./name) 60}}, "{{{./style}}}", "{{./name}}"
51
+ {{/each}}
52
+ end
53
+ {{/each}}
54
+ end
55
+ end
56
+ # :nocov:
57
+ end
@@ -14,8 +14,8 @@ module DrawioDsl
14
14
  end
15
15
  {{#each shapes}}
16
16
 
17
- def {{snake ./type}}(**opts)
18
- builder.add_{{snake ./type}}(**opts)
17
+ def {{snake ./type}}(**opts, &block)
18
+ builder.add_{{snake ./type}}(**opts, &block)
19
19
  end
20
20
  {{/each}}
21
21
  end
@@ -1,4 +1,4 @@
1
- KManager.model :shapes, namespace: %i[domain] do
1
+ m = KManager.model :shapes, namespace: %i[domain] do
2
2
  # microapp = import(:handlebars_helpers, :microapp)
3
3
 
4
4
  table :shapes do
@@ -24,16 +24,18 @@ KManager.model :shapes, namespace: %i[domain] do
24
24
  row :callout4 , false, 0, 0, 160, 120, 'shape=mxgraph.basic.roundRectCallout;dx=30;dy=15;size=5;boundedLbl=1;'
25
25
  row :circle , false, 0, 0, 160, 160, 'ellipse'
26
26
  row :cloud , false, 0, 0, 160, 160, 'shape=cloud'
27
+ row :container , false, 0, 0, 160, 160, 'swimlane'
28
+ row :container2 , false, 0, 0, 160, 160, 'swimlane;horizontal=0'
29
+ row :container3 , false, 0, 0, 160, 160, 'swimlane;startSize=50'
30
+ row :container4 , false, 0, 0, 160, 160, 'swimlane;resizable=0'
27
31
  row :cross , false, 0, 0, 50, 50, 'verticalLabelPosition=bottom;verticalAlign=top;html=1;shape=mxgraph.basic.x'
28
32
  row :envelop , false, 0, 0, 160, 100, 'shape=message'
29
33
  row :diamond , false, 0, 0, 100, 100, 'rhombus'
30
34
  row :document , false, 0, 0, 160, 160, 'shape=mxgraph.basic.document'
31
35
  row :ellipse , false, 0, 0, 200, 120, 'ellipse'
32
36
  row :hexagon , false, 0, 0, 200, 120, 'shape=hexagon'
33
- row :container , false, 0, 0, 160, 160, 'swimlane'
34
- row :container2 , false, 0, 0, 160, 160, 'swimlane;horizontal=0'
35
- row :container3 , false, 0, 0, 160, 160, 'swimlane;startSize=50'
36
- row :container4 , false, 0, 0, 160, 160, 'swimlane;resizable=0'
37
+ row :interface , false, 0, 0, 160, 160, 'align=left;overflow=fill;fontSize=12;fontFamily=Helvetica'
38
+ row :klass , false, 0, 0, 160, 160, 'align=left;overflow=fill;fontSize=12;fontFamily=Helvetica'
37
39
  row :note , false, 0, 0, 160, 160, 'shape=note'
38
40
  row :process , false, 0, 0, 200, 120, 'shape=process'
39
41
  row :rectangle , false, 0, 0, 200, 120, ''
@@ -41,6 +43,7 @@ KManager.model :shapes, namespace: %i[domain] do
41
43
  row :square , false, 0, 0, 160, 160, ''
42
44
  row :step , false, 0, 0, 120, 80, 'shape=step;perimeter=stepPerimeter;fixedSize=1'
43
45
  row :tick , false, 0, 0, 50, 50, 'verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.tick'
46
+ row :todo , false, 0, 0, 300, 60, ''
44
47
  row :face , false, 0, 0, 100, 100, 'verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.smiley'
45
48
  row :triangle , false, 0, 0, 100, 100, 'triangle'
46
49
 
@@ -60,3 +63,5 @@ KManager.model :shapes, namespace: %i[domain] do
60
63
  .add_file('shapes.json', content: shapes, on_exist: :write)
61
64
  end
62
65
  end
66
+
67
+
@@ -0,0 +1,195 @@
1
+ KManager.action :transform_drawio_js do
2
+
3
+ action do
4
+ director = KDirector::Dsls::BasicDsl
5
+ .init(k_builder,
6
+ on_exist: :write, # %i[skip write compare]
7
+ on_action: :execute # %i[queue execute]
8
+ )
9
+ .blueprint do
10
+ cd(:data)
11
+
12
+ source_file = '/Users/davidcruwys/dev/tools/drawio-desktop/drawio/src/main/webapp/js/diagramly/Extensions.js'
13
+ target_file = k_builder.target_folders.get_filename(:data, 'extensions.js')
14
+
15
+ clean = CleanExtensionsJs.new(source_file, target_file)
16
+
17
+ cd(:lib)
18
+
19
+ clean.parse
20
+
21
+ add_file('drawio_extensions.json', content: clean.build_json)
22
+ add('drawio_extensions.rb', constants: clean.constants, sections: clean.sections)
23
+ end
24
+ end
25
+ end
26
+
27
+ class CleanExtensionsJs
28
+ def initialize(source_file, target_file)
29
+ @source_file = source_file
30
+ @target_file = target_file
31
+ @source = File.read(@source_file)
32
+ @constants = []
33
+ @builder = ExtensionJsBuilder.new
34
+ end
35
+
36
+ def parse
37
+ split_source
38
+ end
39
+
40
+ def build_json
41
+ @builder.build_json
42
+ end
43
+
44
+ def build_ruby
45
+ @builder.build_ruby
46
+ end
47
+
48
+ def constants
49
+ @builder.constants.join("\n")
50
+ end
51
+
52
+ def sections
53
+ @builder.sections.select { |s| s[:shapes].length > 0 }
54
+ end
55
+
56
+ private
57
+
58
+ def split_source
59
+ source_lines = @source.split("\n")
60
+ section = :unknown
61
+
62
+ source_lines.each do |line|
63
+ if line.include?('// Global import transformation')
64
+ section = :constants
65
+ next
66
+ elsif line.include?('var styleMap = {') && !line.include?('var styleMap = {};')
67
+ puts '-----------------------------------'
68
+ section = :style_map
69
+ next
70
+ elsif line.include?('};') ||
71
+ line.include?('//Instead of doing a massive code refactoring, thees ugly global variables are used')
72
+ section = :unknown
73
+ end
74
+
75
+ if section == :constants
76
+ @builder.process_constant(line)
77
+ end
78
+
79
+ if section == :style_map
80
+ @builder.process_style_map(line)
81
+ end
82
+ end
83
+ end
84
+
85
+ def process_style_map(line)
86
+ line
87
+ end
88
+ end
89
+
90
+ class ExtensionJsBuilder
91
+ attr_accessor :constants
92
+ attr_accessor :shapes
93
+ attr_accessor :sections
94
+ attr_accessor :current_section
95
+
96
+ def initialize
97
+ @constants = []
98
+ @shapes = []
99
+ @sections = []
100
+ @current_section = nil
101
+ end
102
+
103
+ def process_constant(line)
104
+ line = line.gsub(' ', '').gsub('var ', '').gsub(/;$/, '')
105
+ @constants << " #{line}"
106
+ end
107
+
108
+ def process_style_map(line)
109
+ line = clean_line(line)
110
+
111
+ return if kill_line(line)
112
+
113
+ if line.start_with?('#')
114
+ set_section(line)
115
+ return
116
+ end
117
+
118
+ return unless current_section
119
+
120
+ parts = process_line(line)
121
+
122
+ if parts.length == 2
123
+ name = parts[0]
124
+ style = parts[1]
125
+ current_section[:shapes] << { name: name, style: style }
126
+ shapes << line
127
+ else
128
+ puts 'length not 2'
129
+ puts line
130
+ end
131
+ end
132
+
133
+ def process_line(line)
134
+ line.split(':').map { |s| s.strip.gsub('"', '') }
135
+ end
136
+
137
+ def clean_line(line)
138
+ line
139
+ .strip
140
+ .gsub(' ', ' ')
141
+ .gsub(' ', ' ')
142
+ .gsub(' :', ':')
143
+ .gsub("don't", 'do not')
144
+ .gsub('//TODO', '')
145
+ .gsub(/(\/\/)([^ ])/) do |_|
146
+ match = Regexp.last_match
147
+ "// #{match[2]}"
148
+ end
149
+ .gsub("'", '"')
150
+ .gsub('not all variants covered', '')
151
+ .gsub('Timeline shape', '')
152
+ .gsub('# not all variants covered', '')
153
+ .gsub('not all versions supported', '')
154
+ .gsub('ss + "', '"#{ss}')
155
+ .gsub('s + "', '"#{s}')
156
+ .gsub('cs,', '#{cs}')
157
+ .gsub(/cs$/, '#{cs}')
158
+ .gsub('" + containerStyle', '#{containerStyle}"')
159
+ .gsub('kupIcon + "', '"#{kupIcon}')
160
+ .gsub('gcpIcon + "', '"#{gcpIcon}')
161
+ .gsub('azur19 + "', '"#{azur19}')
162
+ .gsub('ssAzure + "', '"#{ssAzure}')
163
+ .gsub('" + arcSize + "', '#{arcSize}')
164
+ .gsub('//', '#')
165
+ .gsub(' ', ' ')
166
+ .gsub(', #', '')
167
+ .strip
168
+ .gsub(/,$/, '')
169
+ .strip
170
+ end
171
+
172
+ def kill_line(line)
173
+ line.end_with?('NA') ||
174
+ line.end_with?('not working properly, needs specific code)') ||
175
+ line.start_with?('Timeline shapes are postponed, this code is a work-in-progress') ||
176
+ line.start_with?('# *******') ||
177
+ line.start_with?('# 2019 mapping') ||
178
+ line.include?('# "') ||
179
+ line.include?('# "') ||
180
+ line.empty?
181
+ end
182
+
183
+ def set_section(line)
184
+ section = line.gsub('#', '').strip
185
+ @current_section = {
186
+ name: section,
187
+ shapes: []
188
+ }
189
+ @sections << current_section
190
+ end
191
+
192
+ def build_json
193
+ JSON.pretty_generate(@sections)
194
+ end
195
+ end
@@ -0,0 +1,41 @@
1
+ KManager.action :transform_drawio_js do
2
+
3
+ action do
4
+ director = DrawioDsl::Drawio
5
+ .init(k_builder, on_exist: :write, on_action: :execute)
6
+ .diagram(theme: :style_10)
7
+
8
+ ext = DrawioDsl::DrawIoExtensions.new
9
+ ext.build_extensions
10
+ puts ext.sections.length
11
+
12
+ ext.sections.select { |s| s[:active] }.each do |section|
13
+ director.page(section[:name]) do
14
+ grid_layout(wrap_at: 5)
15
+ puts section[:name]
16
+ puts section[:shapes]
17
+ section[:shapes].select { |s| s[:active] }.each do |shape|
18
+ square(title: shape[:name], style_modifiers: shape[:style])
19
+ log.kv(:title, shape[:name])
20
+ log.kv(:style, shape[:style])
21
+ end
22
+ end
23
+ end
24
+ director
25
+ .cd(:spec)
26
+ .save('.samples/20-extensions.drawio')
27
+ .cd(:docs)
28
+
29
+ markdown = "# Extensions\n\n"
30
+
31
+ director.builder.diagram.pages.each_with_index do |page, index|
32
+ page_no = index+1
33
+ puts "Page #{page_no}, #{page.name}"
34
+ # director.export_svg("extensions/#{page.name}", page: page_no)
35
+ markdown += "## #{page.name}\n\n![](./extensions/#{page.name}.svg)\n\n"
36
+ end
37
+
38
+ director
39
+ .add('extensions.md', content: markdown)
40
+ end
41
+ end
@@ -11,8 +11,9 @@ KManager.action :todo_drawio_dsl do
11
11
 
12
12
  grid_layout(y:90, direction: :horizontal, grid_h: 80, grid_w: 320, wrap_at: 3, grid: 0)
13
13
 
14
- square(w: 300, h: 60, title: 'First level child nodes need to hang of node 1')
15
- square(w: 300, h: 60, title: 'Add page background to theme, use it whenever the theme is set at a diagram/page level')
14
+ todo(title: 'move DrawioDsl::Formatters::Factory::FORMATTERS to resource file')
15
+ todo(title: 'move DrawioDsl::Formatters::StyleBuilder::MAPPINGS to resource file')
16
+
16
17
  end
17
18
  .page('To Do', theme: :style_02, margin_left: 0, margin_top: 0) do
18
19
 
@@ -21,19 +22,18 @@ KManager.action :todo_drawio_dsl do
21
22
 
22
23
  grid_layout(y:90, direction: :horizontal, grid_h: 80, grid_w: 320, wrap_at: 3, grid: 0)
23
24
 
24
- square(w: 300, h: 60, title: 'write SVG directly into other projects')
25
- square(w: 300, h: 60, title: 'add :shape and :text-only to random shape generator')
26
- square(w: 300, h: 60, title: 'Nodes need to support child nodes')
27
- square(w: 300, h: 60, title: 'Grid layout does no position itself in relation to the last element')
28
- square(w: 300, h: 60, title: 'Dynamic sized shapes that expand to the size of their text')
29
- square(w: 300, h: 60, title: 'Control of text padding left, right, top and bottom')
30
- square(w: 300, h: 60, title: 'Improve the theme control over text-only shapes')
31
- square(w: 300, h: 60, title: 'x,y settings do not work for shapes within a grid layout')
32
- square(w: 300, h: 60, title: 'background color does not work from the diagram object')
33
- square(w: 300, h: 60, title: 'settings style attributes need to de-duplicate')
34
- square(w: 300, h: 60, title: 'need to setup new project plans')
35
- square(w: 300, h: 60, title: 'write SVG directly into other projects')
36
- square(w: 300, h: 60, title: 'page layout so that you drop elements on and they are positioned correctly, e.g centered, left, right, etc, maybe a grid layout with a wrap of 1 and a width of the page is sufficient')
25
+ todo(title: 'Add page background to theme, use it whenever the theme is set at a diagram/page level')
26
+ todo(title: 'need to setup new project plans')
27
+ todo(title: 'settings style attributes need to de-duplicate, might be best to utilize the new StyleBuilder class')
28
+ todo(title: 'write SVG directly into other projects')
29
+ todo(title: 'add :shape and :text-only to random shape generator')
30
+ todo(title: 'Nodes need to support child nodes')
31
+ todo(title: 'Grid layout does not position itself in relation to the last element')
32
+ todo(title: 'Dynamic sized shapes that expand to the size of their text')
33
+ todo(title: 'Control of text padding left, right, top and bottom')
34
+ todo(title: 'Improve the theme control over text-only shapes')
35
+ todo(title: 'x,y settings do not work for shapes within a grid layout')
36
+ todo(title: 'page layout so that you drop elements on and they are positioned correctly, e.g centered, left, right, etc, maybe a grid layout with a wrap of 1 and a width of the page is sufficient')
37
37
  end
38
38
  .page('Done', theme: :style_06, margin_left: 0, margin_top: 0) do
39
39
 
@@ -42,12 +42,21 @@ KManager.action :todo_drawio_dsl do
42
42
 
43
43
  grid_layout(y:90, direction: :horizontal, grid_h: 80, grid_w: 320, wrap_at: 3, grid: 0)
44
44
 
45
- square(w: 300, h: 60, title: 'Nodes can belong to a parent node, the top level node responds with truthy to root?')
46
- square(w: 300, h: 60, title: 'add sample diagram for the github readme file')
47
- square(w: 300, h: 60, title: 'write samples into docs folder and display in readme')
48
- square(w: 300, h: 60, title: 'add export as .PNG, needs to take a page number as the PNG will not support multiple pages')
49
- square(w: 300, h: 60, title: 'add export as .SVG, needs to take a page number as the SVG will not support multiple pages')
50
- square(w: 300, h: 60, title: 'add save as .drawio')
45
+ todo(title: 'alter configure_shape so it sets the default shape key and use that for selecting the default HTML formatter')
46
+ todo(title: 'Add todo shape to simplify project plan drawing')
47
+ todo(title: 'introduce .value property to shape and let it use either formatted HTML or plain text title')
48
+ todo(title: 'formatter DSL that can render HTML directly into the value property')
49
+ todo(title: 'formatter DSL for class and interface generation')
50
+ todo(title: 'generate extension based graphics based on drawio extensions.js')
51
+ todo(title: 'active? flag on page defaulting to true. set to false to exclude page from diagram.')
52
+ todo(title: 'first level child nodes need to hang of node 1')
53
+ todo(title: 'node has child nodes and add_node will set a nodes parent')
54
+ todo(title: 'nodes can belong to a parent node, the top level node responds with truthy to root?')
55
+ todo(title: 'add sample diagram for the github readme file')
56
+ todo(title: 'write samples into docs folder and display in readme')
57
+ todo(title: 'add export as .PNG, needs to take a page number as the PNG will not support multiple pages')
58
+ todo(title: 'add export as .SVG, needs to take a page number as the SVG will not support multiple pages')
59
+ todo(title: 'add save as .drawio')
51
60
 
52
61
  end
53
62
  .cd(:spec)
@@ -1,13 +1,5 @@
1
1
  KManager.action :bootstrap do
2
2
  action do
3
-
4
- # KConfig.configuration.drawio.square.w = KConfig.configuration.drawio.square.w / 4
5
- # KConfig.configuration.drawio.square.h = KConfig.configuration.drawio.square.h / 4
6
- # KConfig.configuration.drawio.circle.w = KConfig.configuration.drawio.circle.w / 4
7
- # KConfig.configuration.drawio.circle.h = KConfig.configuration.drawio.circle.h / 4
8
- # KConfig.configuration.drawio.rectangle.w = KConfig.configuration.drawio.rectangle.w / 4
9
- # KConfig.configuration.drawio.rectangle.h = KConfig.configuration.drawio.rectangle.h / 4
10
-
11
3
  DrawioDsl::Drawio
12
4
  .init(k_builder, on_exist: :write, on_action: :execute)
13
5
  .diagram(theme: :style_01)
@@ -1,8 +1,7 @@
1
1
  KManager.action :bootstrap do
2
2
  action do
3
3
 
4
- # :rounded, :shadow, :sketch, :glass
5
- director = DrawioDsl::Drawio
4
+ DrawioDsl::Drawio
6
5
  .init(k_builder, on_exist: :write, on_action: :execute)
7
6
  .diagram(theme: :style_06)
8
7
  .page('Style-Plain', margin_left: 0, margin_top: 0) do
@@ -0,0 +1,48 @@
1
+ KManager.action :html_shapes do
2
+ action do
3
+
4
+ # :rounded, :shadow, :sketch, :glass
5
+ DrawioDsl::Drawio
6
+ .init(k_builder, on_exist: :write, on_action: :execute)
7
+ .diagram(theme: :style_11)
8
+ .page('Style-Plain', margin_left: 0, margin_top: 0, rounded: 0, background: '#FFEADB') do
9
+ grid_layout(wrap_at: 8)
10
+
11
+ # html = DrawioDsl::Formatters::InterfaceFormatter.new
12
+ # .header('IPerson')
13
+ # .field(:first_name, type: :string)
14
+ # .field(:last_name, type: :string)
15
+ # .field(:age, type: :integer)
16
+ # .field(:birthday, type: :date)
17
+ # .method(:full_name)
18
+ # .as_html
19
+
20
+ # square(
21
+ # title: html,
22
+ # style_modifiers: 'align=left;overflow=fill;fontSize=12;fontFamily=Helvetica'
23
+ # )
24
+
25
+ interface(theme: :style_07) do
26
+ format
27
+ .header('IPerson')
28
+ .field(:field1, type: :string)
29
+ .field(:field2, type: :string)
30
+ .method(:full_name, type: :string)
31
+ end
32
+
33
+ klass do
34
+ format(:class)
35
+ .header('Person')
36
+ .field(:field1, type: :string)
37
+ .field(:field2, type: :string)
38
+ .field(:age, type: :integer)
39
+ .field(:birthday, type: :date)
40
+ .method(:full_name, type: :string)
41
+ end
42
+ end
43
+ .cd(:spec)
44
+ .save('.samples/30-html-shapes.drawio')
45
+ .cd(:docs)
46
+ .export_svg('samples/html-shapes', page: 1)
47
+ end
48
+ end
data/.rubocop.yml CHANGED
@@ -10,6 +10,7 @@ AllCops:
10
10
  Exclude:
11
11
  - ".builders/**/*"
12
12
  - "spec/samples/**/*"
13
+ - "lib/drawio_dsl/drawio_extensions.rb"
13
14
 
14
15
  Metrics/BlockLength:
15
16
  Exclude:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ # [0.7.0](https://github.com/klueless-io/drawio_dsl/compare/v0.6.0...v0.7.0) (2022-03-14)
2
+
3
+
4
+ ### Features
5
+
6
+ * add support for HTML formatters to shapes ([14b05e2](https://github.com/klueless-io/drawio_dsl/commit/14b05e2c55ea61ad8f275d678ca4fcff8a43b466))
7
+ * add support for html shapes ([d2d0e72](https://github.com/klueless-io/drawio_dsl/commit/d2d0e72bef8f44c244dd209d191ab29aea0091c1))
8
+
9
+ # [0.6.0](https://github.com/klueless-io/drawio_dsl/compare/v0.5.7...v0.6.0) (2022-03-13)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * update failing tests ([37ebbbd](https://github.com/klueless-io/drawio_dsl/commit/37ebbbd37cf70b150c83dbd2a389c6f176a917cf))
15
+ * update pre-commit ([374a29b](https://github.com/klueless-io/drawio_dsl/commit/374a29bad9f50ac01b670d6bfa01e42e9864e00e))
16
+
17
+
18
+ ### Features
19
+
20
+ * first level child nodes need to hang of node 1, build example shapes from extensions.js ([4b233fb](https://github.com/klueless-io/drawio_dsl/commit/4b233fb452eafa8052e7d5014e19bec07ecf5657))
21
+
22
+ ## [0.5.7](https://github.com/klueless-io/drawio_dsl/compare/v0.5.6...v0.5.7) (2022-03-09)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * Nodes can belong to a parent node, the top level node responds with truthy to root? ([3ab5dad](https://github.com/klueless-io/drawio_dsl/commit/3ab5dad60a81880cb603be9ab9f82994d8ac2562))
28
+
1
29
  ## [0.5.6](https://github.com/klueless-io/drawio_dsl/compare/v0.5.5...v0.5.6) (2022-03-08)
2
30
 
3
31